<template>
    <div v-loading="loading" class="dictionary">
        <el-container class="box common" style="border: 1px solid #eee;height: 100%">
            <el-aside class="role">
                <el-header class="headers common">
                    <div style="margin: 10px 10px 0 10px;display: flex;flex-direction: row;">
                        <el-form-item :label="$t('webAuto.DictionarySetName')" style="margin:0 10px 8px 0;">
                            <el-input v-model="data.typeName" :placeholder="$t('webAuto.name')" clearable />
                        </el-form-item>
                        <el-form-item :label="$t('webAuto.DictionarySetCode')" style="margin:0 0 8px 0;">
                            <el-input v-model="data.typeCode" :placeholder="$t('webAuto.code')" clearable />
                        </el-form-item>
                    </div>
                    <el-row style="margin: 0 10px;">
                        <el-button type="success" @click="data.dialogValueVisible = true, data.isshow = true"
                            class="button"><el-icon>
                                <CirclePlus />
                            </el-icon>{{ $t('webAuto.newlyAdded') }}</el-button>
                        <el-button type="primary" @click="editVualueSet" class="button"><el-icon>
                                <Edit />
                            </el-icon>{{ $t('webAuto.edit') }}</el-button>
                        <el-button type="danger" @click="deleteVualueSet" class="button"><el-icon>
                                <Close />
                            </el-icon>{{ $t('webAuto.delete') }}</el-button>
                        <el-button plain @click="valueSet()" class="button"><el-icon>
                                <Search />
                            </el-icon>{{ $t('webAuto.query') }}</el-button>
                        <el-button type="info" class="button" plain @click="restOne"><el-icon>
                                <RefreshLeft />
                            </el-icon>{{ $t('calendar.rest') }}</el-button>
                    </el-row>
                </el-header>
                <el-main class="tables common">
                    <el-table :data="data.tableValue" style="width: 100%;height: 95%;" border
                        :header-cell-style="{ color: '#000', fontWeight: 'bold' }" highlight-current-row
                        @current-change="highlightCurrentChange" :cell-style="{ whiteSpace: 'pre-wrap' }">
                        <el-table-column type="selection" width="55">
                            <template #default="scope">
                                <el-checkbox v-model="scope.row.selected" />
                            </template>
                        </el-table-column>
                        <el-table-column prop="typeName" :label="$t('webAuto.DictionarySetName')" width='120' />
                        <el-table-column prop="typeCode" :label="$t('webAuto.DictionarySetCode')" />
                        <el-table-column prop="sequence" :label="$t('webAuto.sort')" width='70' />
                        <el-table-column prop="remark" :label="$t('webAuto.notes')" />
                    </el-table>
                    <div class="demo-pagination-block">
                        <el-pagination :currentPage="data.currentPage" :page-size="data.pageSize"
                            :page-sizes="[15, 30, 50]" :small="small" :disabled="disabled" :background="background"
                            layout="total, sizes, prev, pager, next, jumper" :total="data.total"
                            @size-change="handleSizeChange" @current-change="handleCurrentChange" />
                    </div>
                </el-main>
            </el-aside>
            <el-main class="details">
                <el-header class="role-heaer common">
                    <div style="margin: 10px 10px 0 10px;display: flex;flex-direction: row;">
                        <el-form-item :label="$t('webAuto.DicItemSetName')" style="margin:0 10px 8px 0;">
                            <el-input v-model="data.itemValue" :placeholder="$t('webAuto.name')" clearable />
                        </el-form-item>
                        <el-form-item :label="$t('webAuto.DicItemSetCode')" style="margin:0 0 8px 0;">
                            <el-input v-model="data.itemCode" :placeholder="$t('webAuto.code')" clearable />
                        </el-form-item>
                    </div>
                    <el-row style="margin: 0 10px;">
                        <el-button type="success" @click="addItem" class="button"><el-icon>
                                <CirclePlus />
                            </el-icon>{{ $t('webAuto.newlyAdded') }}</el-button>
                        <el-button type="primary" @click="editItem" class="button"><el-icon>
                                <Edit />
                            </el-icon>{{ $t('webAuto.edit') }}</el-button>
                        <el-button type="danger" @click="deleteItem" class="button"><el-icon>
                                <Close />
                            </el-icon>{{ $t('webAuto.delete') }}</el-button>
                        <el-button plain @click="dictionary()" class="button"><el-icon>
                                <Search />
                            </el-icon>{{ $t('webAuto.query') }}</el-button>
                        <el-button type="info" class="button" plain @click="rest2"><el-icon>
                                <RefreshLeft />
                            </el-icon>{{ $t('calendar.rest') }}</el-button>
                    </el-row>
                </el-header>
                <el-main class="tables common">
                    <el-table :data="data.tableList" style="height: 95%;" border
                        :header-cell-style="{ color: '#000', fontWeight: 'bold' }" highlight-current-row
                        @current-change="highlightCurrentChange2" :cell-style="{ whiteSpace: 'pre-wrap' }">
                        <!-- @row-dblclick="rowClick" -->
                        <el-table-column type="selection" width="55" fixed="left">
                            <template #default="scope">
                                <el-checkbox v-model="scope.row.selected" />
                            </template>
                        </el-table-column>
                        <el-table-column prop="code" :label="$t('webAuto.DicItemSetName')" width="130" fixed="left" />
                        <el-table-column prop="value" :label="$t('webAuto.DicItemSetCode')" width="130" fixed="left" />
                        <el-table-column prop="text" :label="$t('webAuto.text')" fixed="left" />
                        <el-table-column prop="typeCode" :label="$t('webAuto.type')" />
                        <el-table-column prop="sequence" :label="$t('webAuto.sort')" width="70" />
                        <el-table-column prop="remark" :label="$t('webAuto.notes')" />
                        <el-table-column prop="attribute1" :label="$t('webAuto.Note1')" />
                        <el-table-column prop="attribute2" :label="$t('webAuto.Note2')" />
                        <el-table-column prop="attribute3" :label="$t('webAuto.Note3')" />
                        <el-table-column prop="attribute4" :label="$t('webAuto.notes') + 4" />
                        <el-table-column prop="attribute5" :label="$t('webAuto.notes') + 5" />
                        <el-table-column prop="attribute6" :label="$t('webAuto.notes') + 6" />
                        <el-table-column prop="attribute7" :label="$t('webAuto.notes') + 7" />
                        <el-table-column prop="attribute8" :label="$t('webAuto.notes') + 8" />
                        <el-table-column prop="attribute9" :label="$t('webAuto.notes') + 9" />
                        <el-table-column prop="attribute10" :label="$t('webAuto.notes') + 10" />
                        <el-table-column prop="attribute11" :label="$t('webAuto.notes') + 11" />
                        <el-table-column prop="attribute12" :label="$t('webAuto.notes') + 12" />
                        <el-table-column prop="attribute13" :label="$t('webAuto.notes') + 13" />
                        <el-table-column prop="attribute14" :label="$t('webAuto.notes') + 14" />
                        <el-table-column prop="attribute15" :label="$t('webAuto.notes') + 15" />
                        <el-table-column prop="attribute16" :label="$t('webAuto.notes') + 16" />
                        <el-table-column prop="attribute17" :label="$t('webAuto.notes') + 17" />
                        <el-table-column prop="attribute18" :label="$t('webAuto.notes') + 18" />
                        <el-table-column prop="attribute19" :label="$t('webAuto.notes') + 19" />
                        <el-table-column prop="attribute20" :label="$t('webAuto.notes') + 20" />
                    </el-table>
                    <div class="demo-pagination-block">
                        <el-pagination :currentPage="data.currentPage2" :page-size="data.pageSize2"
                            :page-sizes="[15, 30, 50]" :small="small" :disabled="disabled" :background="background"
                            layout="total, sizes, prev, pager, next, jumper" :total="data.total2"
                            @size-change="handleSizeChange2" @current-change="handleCurrentChange2" />
                    </div>
                </el-main>
            </el-main>
        </el-container>
        <!-- 值集主表弹框 -->
        <el-dialog v-if="data.dialogValueVisible" v-model="data.dialogValueVisible"
            :title="data.isshow ? $t('webAuto.AddDictionary') : $t('webAuto.UpdateDictionary')" width="700"
            destroy-on-close :close-on-click-modal="false">
            <el-form :model="form" ref="ruleFormRef" :rules="rules">
                <el-form-item :label="$t('webAuto.DictionarySetName')" :label-width="100" prop="typeName">
                    <el-input v-model="form.typeName" />
                </el-form-item>
                <el-form-item :label="$t('webAuto.DictionarySetCode')" :label-width="100" prop="typeCode">
                    <el-input v-model="form.typeCode" />
                </el-form-item>
                <el-form-item :label="$t('webAuto.sort')" :label-width="100">
                    <el-input v-model="form.sequence" />
                </el-form-item>
                <el-form-item :label="$t('webAuto.notes')" :label-width="100">
                    <el-input v-model="form.remark" />
                </el-form-item>
            </el-form>
            <template #footer>
                <div class="dialog-footer">
                    <el-button @click="data.dialogValueVisible = false">{{ $t('webAuto.cancel') }}</el-button>
                    <el-button type="primary" v-if="data.isshow" @click="saveClick">
                        {{ $t('webAuto.bangcun') }}
                    </el-button>
                    <el-button type="primary" @click="updateClick" v-else>
                        {{ $t('webAuto.gengxing') }}
                    </el-button>
                </div>
            </template>
        </el-dialog>
        <!-- 值集子表弹框 -->
        <el-dialog v-if="data.dialogItemVisible" v-model="data.dialogItemVisible"
            :title="data.itemShow ? $t('webAuto.AddDicItem') : $t('webAuto.UpdateDicItem')" width="70%" destroy-on-close
            :close-on-click-modal="false">
            <el-form :model="form2" ref="ruleFormRef2" :rules="rules2">
                <el-row>
                    <el-col :span="8">
                        <el-form-item :label="$t('webAuto.DicItemSetName')" :label-width="100" prop="code">
                            <el-input v-model="form2.code" />
                        </el-form-item>
                    </el-col>
                    <el-col :span="8">
                        <el-form-item :label="$t('webAuto.DicItemSetCode')" :label-width="100" prop="value">
                            <el-input v-model="form2.value" />
                        </el-form-item>
                    </el-col>
                    <el-col :span="8">
                        <el-form-item :label="$t('webAuto.text')" :label-width="100">
                            <el-input v-model="form2.text" />
                        </el-form-item>
                    </el-col>
                    <el-col :span="8">
                        <el-form-item :label="$t('webAuto.type')" :label-width="100">
                            <el-input v-model="form2.typeCode" />
                        </el-form-item>
                    </el-col>
                    <el-col :span="8">
                        <el-form-item :label="$t('webAuto.sort')" :label-width="100">
                            <el-input v-model="form2.sequence" />
                        </el-form-item>
                    </el-col>
                    <el-col :span="8">
                        <el-form-item :label="$t('webAuto.notes')" :label-width="100">
                            <el-input v-model="form2.remark" />
                        </el-form-item>
                    </el-col>
                    <el-col :span="8">
                        <el-form-item :label="$t('webAuto.Note1')" :label-width="100">
                            <el-input v-model="form2.attribute1" />
                        </el-form-item>
                    </el-col>
                    <el-col :span="8">
                        <el-form-item :label="$t('webAuto.Note2')" :label-width="100">
                            <el-input v-model="form2.attribute2" />
                        </el-form-item>
                    </el-col>
                    <el-col :span="8">
                        <el-form-item :label="$t('webAuto.Note3')" :label-width="100">
                            <el-input v-model="form2.attribute3" />
                        </el-form-item>
                    </el-col>
                    <el-col :span="8">
                        <el-form-item :label="$t('webAuto.notes') + 4" :label-width="100">
                            <el-input v-model="form2.attribute4" />
                        </el-form-item>
                    </el-col>
                    <el-col :span="8">
                        <el-form-item :label="$t('webAuto.notes') + 5" :label-width="100">
                            <el-input v-model="form2.attribute5" />
                        </el-form-item>
                    </el-col>
                    <el-col :span="8">
                        <el-form-item :label="$t('webAuto.notes') + 6" :label-width="100">
                            <el-input v-model="form2.attribute6" />
                        </el-form-item>
                    </el-col>
                    <el-col :span="8">
                        <el-form-item :label="$t('webAuto.notes') + 7" :label-width="100">
                            <el-input v-model="form2.attribute7" />
                        </el-form-item>
                    </el-col>
                    <el-col :span="8">
                        <el-form-item :label="$t('webAuto.notes') + 8" :label-width="100">
                            <el-input v-model="form2.attribute8" />
                        </el-form-item>
                    </el-col>
                    <el-col :span="8">
                        <el-form-item :label="$t('webAuto.notes') + 9" :label-width="100">
                            <el-input v-model="form2.attribute9" />
                        </el-form-item>
                    </el-col>
                    <el-col :span="8">
                        <el-form-item :label="$t('webAuto.notes') + 10" :label-width="100">
                            <el-input v-model="form2.attribute10" />
                        </el-form-item>
                    </el-col>
                    <el-col :span="8">
                        <el-form-item :label="$t('webAuto.notes') + 11" :label-width="100">
                            <el-input v-model="form2.attribute11" />
                        </el-form-item>
                    </el-col>
                    <el-col :span="8">
                        <el-form-item :label="$t('webAuto.notes') + 12" :label-width="100">
                            <el-input v-model="form2.attribute12" />
                        </el-form-item>
                    </el-col>
                    <el-col :span="8">
                        <el-form-item :label="$t('webAuto.notes') + 13" :label-width="100">
                            <el-input v-model="form2.attribute13" />
                        </el-form-item>
                    </el-col>
                    <el-col :span="8">
                        <el-form-item :label="$t('webAuto.notes') + 14" :label-width="100">
                            <el-input v-model="form2.attribute14" />
                        </el-form-item>
                    </el-col>
                    <el-col :span="8">
                        <el-form-item :label="$t('webAuto.notes') + 15" :label-width="100">
                            <el-input v-model="form2.attribute15" />
                        </el-form-item>
                    </el-col>
                    <el-col :span="8">
                        <el-form-item :label="$t('webAuto.notes') + 16" :label-width="100">
                            <el-input v-model="form2.attribute16" />
                        </el-form-item>
                    </el-col>
                    <el-col :span="8">
                        <el-form-item :label="$t('webAuto.notes') + 17" :label-width="100">
                            <el-input v-model="form2.attribute17" />
                        </el-form-item>
                    </el-col>
                    <el-col :span="8">
                        <el-form-item :label="$t('webAuto.notes') + 18" :label-width="100">
                            <el-input v-model="form2.attribute18" />
                        </el-form-item>
                    </el-col>
                    <el-col :span="8">
                        <el-form-item :label="$t('webAuto.notes') + 19" :label-width="100">
                            <el-input v-model="form2.attribute19" />
                        </el-form-item>
                    </el-col>
                    <el-col :span="8">
                        <el-form-item :label="$t('webAuto.notes') + 20" :label-width="100">
                            <el-input v-model="form2.attribute20" />
                        </el-form-item>
                    </el-col>
                </el-row>
            </el-form>
            <template #footer>
                <div class="dialog-footer">
                    <el-button @click="data.dialogItemVisible = false">{{ $t('webAuto.cancel') }}</el-button>
                    <el-button type="primary" v-if="data.itemShow" @click="saveItemClick">
                        {{ $t('webAuto.bangcun') }}
                    </el-button>
                    <el-button type="primary" @click="updateItemClick" v-else>
                        {{ $t('webAuto.gengxing') }}
                    </el-button>
                </div>
            </template>
        </el-dialog>
    </div>
</template>

<script setup>
import { getBaseinfoH, baseinfoHSave, baseinfoHUpdate, baseinfoHDelete, getBaseinfoD, baseinfoDSave, baseinfoDUpdate, baseinfoDDelete } from '@/api/valueSet'
import { onMounted, reactive, ref, computed } from 'vue';
import { ElMessage, ElMessageBox } from 'element-plus'
import { useI18n } from 'vue-i18n';


const { t } = useI18n();
// 表格绑定的样式
const small = ref(false)
const background = ref(false)
const disabled = ref(false)
let loading = ref('false')
const data = reactive({
    tableValue: [],
    isshow: false,
    dialogValueVisible: false,
    pageSize: 15,
    currentPage: 1,
    total: 0,
    typeCode: '',
    typeName: '',
    rowLi: {},
    dialogItemVisible: false,
    itemShow: false,
    tableList: [],
    currentPage2: 1,
    pageSize2: 15,
    total2: 0,
    rowLis: {},
    itemValue: '',
    itemCode: '',
})

const form = reactive({
    typeName: '',
    typeCode: '',
    sequence: '',
    remark: '',
})

const ruleFormRef = ref(null)
const rules = reactive({
    typeName: [{ required: true, message: t('webAuto.enterDictionaryName'), trigger: 'blur' }],
    typeCode: [{ required: true, message: t('webAuto.enterDictionaryCode'), trigger: 'blur' }],
    sequence: [{ required: true, message: t('webAuto.enterSort'), trigger: 'blur' }],
    remark: [{ required: true, message: t('webAuto.enterNotes'), trigger: 'blur' }],
})
//表单验证
const validator = async (callback) => {
    try {
        return await ruleFormRef.value.validate()
    }
    catch (error) {
        return false
    }

}
const form2 = reactive({
    code: '',
    value: '',
    text: '',
    typeCode: '',
    sequence: '',
    remark: '',
    attribute1: '',
    attribute2: '',
    attribute3: '',
    attribute4: '',
    attribute5: '',
    attribute6: '',
    attribute7: '',
    attribute8: '',
    attribute9: '',
    attribute10: '',
    attribute11: '',
    attribute12: '',
    attribute13: '',
    attribute14: '',
    attribute15: '',
    attribute16: '',
    attribute17: '',
    attribute18: '',
    attribute19: '',
    attribute20: '',
})
const ruleFormRef2 = ref(null)
const rules2 = reactive({
    code: [{ required: true, message: t('webAuto.enterDicItemName'), trigger: 'blur' }],
    value: [{ required: true, message: t('webAuto.enterDicItemCode'), trigger: 'blur' }],
    text: [{ required: true, message: t('webAuto.enterText'), trigger: 'blur' }],
    typeCode: [{ required: true, message: t('webAuto.enterType'), trigger: 'blur' }],
})
//表单验证
const validator2 = async (callback) => {
    try {
        return await ruleFormRef2.value.validate()
    }
    catch (error) {
        return false
    }

}

onMounted(() => {
    loading.value = false
    valueSet()
})

const valueSet = () => {
    getBaseinfoH({
        pageSize: data.pageSize,
        pageNo: data.currentPage,
        typeCode: data.typeCode,
        typeName: data.typeName
    }).then(res => {
        data.tableValue = res.data.records
        data.total = res.data.total
    }).catch((e) => {
        data.tableValue = []
        data.total = 0
    })
}

// 表格分页
const handleSizeChange = val => {
    data.pageSize = val
    valueSet()
}
const handleCurrentChange = val => {
    data.currentPage = val
    valueSet()
}

// 重置
const restOne = () => {
    data.typeName = '';
    data.typeCode = '';
    data.rowLi = {};
    highlightCurrentChange(data.rowLi)
    valueSet()
}

const highlightCurrentChange = async(e) => {
    data.rowLi = e
    data.tableValue.forEach(item => {
        if (item.id == data.rowLi?.id) {
            item.selected = true
        } else {
            item.selected = false
        }
    })
   await dictionary()
}

// 值集操作
// 保存
const saveClick = () => {
    let validate = validator().then(result => {
        console.log(result); // 成功：打印 '操作成功！'
    }).catch(error => {
        console.error(error); // 失败：打印 '操作失败！'
    })
    if (!validate) {
        ElMessage.error(t('webAuto.refineFormData'))
        return
    }
    baseinfoHSave(form).then(res => {
        ElMessage({
            message: t('webAuto.baocunChenGong'),
            type: 'success',
        })
        data.dialogValueVisible = false
        form.typeName = ''
        form.typeCode = ''
        form.sequence = ''
        form.remark = ''
        valueSet()
    }).catch(e => {
        ElMessage.error(e + t('webAuto.baocunShiBai'))
    })
}

// 编辑
const editVualueSet = () => {
    if (Object.keys(data.rowLi).length == 0) {
        ElMessage.error(t('webAuto.chooseRow'))
        return
    }
    data.dialogValueVisible = true
    data.isshow = false
    form.typeName = data.rowLi.typeName
    form.typeCode = data.rowLi.typeCode
    form.sequence = data.rowLi.sequence
    form.remark = data.rowLi.remark
    form.id = data.rowLi.id
}
const updateClick = () => {
    validator().then(result => {
        baseinfoHUpdate(form).then(res => {
            ElMessage({
                message: t('webAuto.gengxingChenGong'),
                type: 'success',
            })
            data.dialogValueVisible = false
            form.typeName = ''
            form.typeCode = ''
            form.sequence = ''
            form.remark = ''
            window.location.reload()
            valueSet()
        }).catch(e => {
            ElMessage.error(e + t('webAuto.gengxingShiBai'))
        })
    }).catch(error => {
        ElMessage.error(t('webAuto.refineFormData'))
    })
}

const deleteVualueSet = () => {
    if (!('id' in data.rowLi)) {
        ElMessage.error(t('webAuto.chooseDelRow'))
    } else {
        ElMessageBox.alert(t('webAuto.confirmDic'), t('webAuto.DelmDic'), {
            confirmButtonText: t('webAuto.sure'),
            callback: action => {
                if (action === 'confirm') {
                    // 在用户确认后发送自定义接口请求
                    baseinfoHDelete(data.rowLi.id).then(res => {
                        ElMessage.success(t('webAuto.DeleteSuccessfully'))
                        window.location.reload()
                    }).catch(err => {
                        ElMessage.error(t('webAuto.DeleteFailed'))
                    })
                }
            }
        })
    }
}

const dictionary = () => {
    getBaseinfoD({
        pageSize: data.pageSize2,
        pageNo: data.currentPage2,
        hid: data.rowLi.id,
        code: data.itemValue,
        value: data.itemCode
    }).then(res => {
        data.tableList = res.data.records
        data.total2 = res.data.total
    }).catch(e => {
        data.tableList = []
        data.total2 = 0
    })
}
// 表格分页
const handleSizeChange2 = val => {
    data.pageSize2 = val
    dictionary()
}
const handleCurrentChange2 = val => {
    data.currentPage2 = val
    dictionary()
}

const rest2 = async () => {
    data.itemCode = ''
    data.itemValue = ''
    data.rowLis = {}
    await highlightCurrentChange2(data.rowLis);
    dictionary()
}
const highlightCurrentChange2 = (e) => {
    data.rowLis = e
    data.tableList.forEach(item => {
        if (item.id == data.rowLis?.id) {
            item.selected = true
        } else {
            item.selected = false
        }
    })
}

const addItem = () => {
    if (Object.keys(data.rowLi).length == 0) {
        ElMessage.error(t('webAuto.confirmDicAdd'))
        return
    }
    data.dialogItemVisible = true, data.itemShow = true
}

const saveItemClick = () => {
    form2.hid = data.rowLi.id
    validator2().then(result => {
        console.log(result);
        baseinfoDSave(form2).then(res => {
            ElMessage({
                message: res.data,
                type: 'success',
            })
            data.dialogItemVisible = false
            dictionary()
        }).catch(e => {
            ElMessage.error(e.data)
        })
    }).catch(error => {
        console.error(error); // 失败：打印 '操作失败！'
        ElMessage.error(t('webAuto.refineFormData'))
        return
    })

}
// 编辑
const editItem = () => {
    if (Object.keys(data.rowLis).length == 0) {
        ElMessage.error(t('webAuto.chooseRowDicItem'))
        return
    }
    form2.code = data.rowLis.code
    form2.value = data.rowLis.value
    form2.id = data.rowLis.id
    form2.hid = data.rowLis.hid
    form2.text = data.rowLis.text
    form2.typeCode = data.rowLis.typeCode
    form2.sequence = data.rowLis.sequence
    form2.remark = data.rowLis.remark
    form2.attribute1 = data.rowLis.attribute1
    form2.attribute2 = data.rowLis.attribute2
    form2.attribute3 = data.rowLis.attribute3
    form2.attribute4 = data.rowLis.attribute4
    form2.attribute5 = data.rowLis.attribute5
    form2.attribute6 = data.rowLis.attribute6
    form2.attribute7 = data.rowLis.attribute7
    form2.attribute8 = data.rowLis.attribute8
    form2.attribute9 = data.rowLis.attribute9
    form2.attribute10 = data.rowLis.attribute10
    form2.attribute11 = data.rowLis.attribute11
    form2.attribute12 = data.rowLis.attribute12
    form2.attribute13 = data.rowLis.attribute13
    form2.attribute14 = data.rowLis.attribute14
    form2.attribute15 = data.rowLis.attribute15
    form2.attribute16 = data.rowLis.attribute16
    form2.attribute17 = data.rowLis.attribute17
    form2.attribute18 = data.rowLis.attribute18
    form2.attribute19 = data.rowLis.attribute19
    form2.attribute20 = data.rowLis.attribute20
    data.itemShow = false
    data.dialogItemVisible = true
}
const updateItemClick = () => {
    validator2().then(result => {
        baseinfoDUpdate(form2).then(res => {
            ElMessage({
                message: t('webAuto.gengxingChenGong'),
                type: 'success',
            })
            data.dialogValueVisible = false
            window.location.reload()
            dictionary()
        }).catch(e => {
            ElMessage.error(e + t('webAuto.gengxingShiBai'))
        })
    }).catch(error => {
        ElMessage.error(t('webAuto.refineFormData'))
    })
}

const deleteItem = () => {
    if (!('id' in data.rowLis)) {
        ElMessage.error(t('webAuto.chooseDelRow'))
    } else {
        ElMessageBox.alert(t('webAuto.confirmDicItem'), t('webAuto.DelmDicItem'), {
            confirmButtonText: t('webAuto.sure'),
            callback: action => {
                if (action === 'confirm') {
                    // 在用户确认后发送自定义接口请求
                    baseinfoDDelete(data.rowLis.id).then(res => {
                        ElMessage.success(t('webAuto.DeleteSuccessfully'))
                        window.location.reload()
                    }).catch(err => {
                        ElMessage.error(t('webAuto.DeleteFailed'))
                    })
                }
            }
        })
    }
}
</script>


<style scoped lang="less">
@import "index.less";
</style>